# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Tom Gundersen <teg@jklm.no>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: ice-man <icemanf@gmail.com>
# Contributor: sergeantspoon <sergeantspoon@archlinux.us>

pkgbase=libssh
pkgname=(libssh libssh-docs)
pkgver=0.10.5
pkgrel=1
pkgdesc='Library for accessing ssh client services through C libraries'
url='https://www.libssh.org/'
license=(LGPL)
arch=(loong64 x86_64)
depends=(zlib openssl)
makedepends=(cmake cmocka doxygen python openssh)
provides=(libssh.so)
source=("https://www.libssh.org/files/${pkgver%.*}/$pkgname-$pkgver.tar.xz"{,.asc})
sha256sums=('b60e2ff7f367b9eee2b5634d3a63303ddfede0e6a18dfca88c44a8770e7e4234'
            'SKIP')
validpgpkeys=('8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D') # Andreas Schneider <asn@cryptomilk.org>

build() {
  cmake -B build -S $pkgname-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DWITH_GSSAPI=OFF \
    -DUNIT_TESTING=ON
  cmake --build build
  cmake --build build --target docs
}

check() {
  cmake --build build --target test
}

package_libssh() {
  DESTDIR="$pkgdir" cmake --install build
}

package_libssh-docs() {
  pkgdesc='Documentation for libssh'
  depends=()
  provides=()

  mkdir -p "$pkgdir"/usr/share/doc/libssh
  cp -r build/doc/html "$pkgdir"/usr/share/doc/libssh
#  cp -r build/doc/man "$pkgdir"/usr/share
#  rm "$pkgdir"/usr/share/man/man3/{bug,deprecated}.*
}
